package cn.sc.allinpay.allfavour.business.common.data;

import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;

/**
 * description：电子券信息
 * author：pany
 * on 2018/8/2 16:10
 */
public class CouponsData implements Parcelable, Comparable {
    private String couponCode;//券号
    private String couponName;//券名称
    private String balance;//余额    单位: 分
    private String unit;//单位
    private int type;//类型    0金额 1抵扣 2计次
    private String discountedAmt;//折现额  单位为分
    private String desc;//使用说明
    private String startTime;//起始时间
    private String endTime;//结束时间
    private LimitData limit;//消费限制  仅金额券有该字段
    private ShareData share;//同享限制  仅金额券有该字段
    private String templateCode;//券模板

    private String couponNo;//券号

    private boolean isUse = false;//是否使用 type=0的金额
    private int useNumber = 0;//使用 type=1或2的张数
    private String useAmt;//使用金额，type=0的使用金额

    private String remark;//备注信息

    public CouponsData() {

    }

    protected CouponsData(Parcel in) {
        couponCode = in.readString();
        couponName = in.readString();
        balance = in.readString();
        unit = in.readString();
        type = in.readInt();
        discountedAmt = in.readString();
        desc = in.readString();
        startTime = in.readString();
        endTime = in.readString();
        limit = in.readParcelable(LimitData.class.getClassLoader());
        share = in.readParcelable(ShareData.class.getClassLoader());
        templateCode = in.readString();
        couponNo = in.readString();
        isUse = in.readByte() != 0;
        useNumber = in.readInt();
        useAmt = in.readString();
        remark = in.readString();
    }

    public String getCouponCode() {
        return couponCode;
    }

    public void setCouponCode(String couponCode) {
        this.couponCode = couponCode;
    }

    public String getCouponName() {
        return couponName;
    }

    public void setCouponName(String couponName) {
        this.couponName = couponName;
    }

    public String getBalance() {
        return balance;
    }

    public void setBalance(String balance) {
        this.balance = balance;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getDiscountedAmt() {
        return discountedAmt;
    }

    public void setDiscountedAmt(String discountedAmt) {
        this.discountedAmt = discountedAmt;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public LimitData getLimit() {
        return limit;
    }

    public void setLimit(LimitData limit) {
        this.limit = limit;
    }

    public ShareData getShare() {
        return share;
    }

    public void setShare(ShareData share) {
        this.share = share;
    }

    public String getTemplateCode() {
        return templateCode;
    }

    public void setTemplateCode(String templateCode) {
        this.templateCode = templateCode;
    }

    public String getCouponNo() {
        return couponNo;
    }

    public void setCouponNo(String couponNo) {
        this.couponNo = couponNo;
    }

    public boolean isUse() {
        return isUse;
    }

    public void setUse(boolean use) {
        isUse = use;
    }

    public int getUseNumber() {
        return useNumber;
    }

    public void setUseNumber(int useNumber) {
        this.useNumber = useNumber;
    }

    public String getUseAmt() {
        return useAmt;
    }

    public void setUseAmt(String useAmt) {
        this.useAmt = useAmt;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public static final Creator<CouponsData> CREATOR = new Creator<CouponsData>() {
        @Override
        public CouponsData createFromParcel(Parcel in) {
            return new CouponsData(in);
        }

        @Override
        public CouponsData[] newArray(int size) {
            return new CouponsData[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeString(couponCode);
        parcel.writeString(couponName);
        parcel.writeString(balance);
        parcel.writeString(unit);
        parcel.writeInt(type);
        parcel.writeString(discountedAmt);
        parcel.writeString(desc);
        parcel.writeString(startTime);
        parcel.writeString(endTime);
        parcel.writeParcelable(limit, i);
        parcel.writeParcelable(share, i);
        parcel.writeString(templateCode);
        parcel.writeString(couponNo);
        parcel.writeByte((byte) (isUse ? 1 : 0));
        parcel.writeInt(useNumber);
        parcel.writeString(useAmt);
        parcel.writeString(remark);
    }

    @Override
    public int compareTo(@NonNull Object o) {
        CouponsData couponsData = (CouponsData) o;
      return  this.getDiscountedAmt().compareTo(couponsData.getDiscountedAmt());

    }
}
